# 导包
from selenium.webdriver.common.by import By
from util_tools.basePage import BasePage
from time import sleep
import allure

class FilesUploadPage(BasePage):
    url = 'https://www.leafground.com/file.xhtml'
    files_input = (By.XPATH, '//*[@id="j_idt88:j_idt89_input"]')
    assert_result = (By.XPATH, '//*[@id="j_idt88:j_idt89"]/span[2]')

    def files_upload(self):
        self.open_url(self.url)
        allure.attach(self.url, '打开测试页面', attachment_type=allure.attachment_type.TEXT)
        file_path = r'E:\Users\webuiauto\screenshot\文件上传.txt'

        allure.attach(file_path, '上传文件', attachment_type=allure.attachment_type.TEXT)
        self.send_keys(self.files_input, file_path)
        sleep(3)
        allure.attach(self.screenshots_png(), '文件上传截屏', attachment_type=allure.attachment_type.PNG)
